<%@ page import="com.fduss.artStore.entity.*" %><%--
  Created by IntelliJ IDEA.
  User: duocai wu
  Date: 2017/6/29
  Time: 16:29
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <%--<link rel="icon" href="../../favicon.ico">--%>

    <title>artwork detail</title>

    <!-- Bootstrap core CSS -->
    <link href="./css/bootstrap.min.css" rel="stylesheet">
    <style>
        .margin-top-100 {
            margin-top: 100px;
        }
    </style>
</head>
<body>
    <jsp:useBean id="artworkService" scope="session"
                 class="com.fduss.artStore.service.impl.ArtworkServiceImpl"/>
    <jsp:useBean id="artistService" scope="session"
                 class="com.fduss.artStore.service.impl.ArtistServiceImpl"/>
    <%
        String artworkBase = "./art-images/works/large/";
        String suffix = ".jpg";
        int id = 31;
        try {
            id = Integer.parseInt(request.getParameter("id"));
        }
        catch (Exception e) {
            id = 31;
        }
        Artwork artwork = artworkService.getOne(id);
        if (artwork == null)
            artwork = artworkService.getOne(31);
        Genre genre = artworkService.getGenre(artwork.getArtWorkId());
        Subject subject = artworkService.getSubject(artwork.getArtWorkId());
        Artist artist = artistService.getOne(artwork.getArtistId());
    %>
    <%@include file="header.jsp"%>

    <div class="container margin-top-100">
        <div class="row page-header">
            <input type="hidden" id="artworkID" value="<%=id%>">
            <h2 id="title">
                <%=artwork.getTitle()%>
            </h2>
        </div>
        <div class="row" >
            <div class="col-md-7 col-md-push-5">
                <%--details--%>
                <h3>Product Details</h3>
                <table class="table">
                    <tr>
                        <td>Date</td>
                        <td><%=artwork.getYearOfWork()%></td>
                    </tr>
                    <tr>
                        <td>Medium</td>
                        <td><%=artwork.getMedium()%></td>
                    </tr>
                    <tr>
                        <td>Width</td>
                        <td><%=artwork.getWidth()%></td>
                    </tr>
                    <tr>
                        <td>Height</td>
                        <td><%=artwork.getHeight()%></td>
                    </tr>
                    <tr>
                        <td>Home</td>
                        <td><%=artwork.getOriginalHome()%></td>
                    </tr>
                    <tr>
                        <td>Genres</td>
                        <td>
                            <% if (genre != null) {%>
                                <a href="<%=genre.getLink()%>">
                                    <%=genre.getGenreName()%>
                                </a>
                            <% } %>
                        </td>
                    </tr>
                    <tr>
                        <td>Subjects</td>
                        <td>
                            <% if (subject != null) {%>
                                <%=subject.getSubjectName()%>
                            <% } %>
                        </td>
                    </tr>
                    <tr>
                        <td>Costs</td>
                        <td><%=artwork.getCost()%></td>
                    </tr>
                    <tr>
                        <td>MSRP</td>
                        <td><%=artwork.getMsrp()%></td>
                    </tr>
                    <tr>
                        <td>Artist</td>
                        <td>
                            <%if (artist != null) {%>
                                <a href="<%=artist.getArtistLink()%>">
                                    <%=artist.getFirstName() + " " + artist.getLastName()%>
                                </a>
                            <% } %>
                        </td>
                    </tr>
                    <tr>
                        <td>Link</td>
                        <td>
                            <a href="<%=artwork.getArtWorkLink() != null ? artwork.getArtWorkLink():"#"%>">
                                <%=artwork.getArtWorkLink() != null ? artwork.getArtWorkLink():""%></a>
                        </td>
                    </tr>
                    <tr>
                        <td>Google Link</td>
                        <td>
                            <a href="<%=artwork.getGoogleLink() != null ? artwork.getGoogleLink():"#"%>">
                                <%=artwork.getGoogleLink() != null ? artwork.getGoogleLink():""%></a>
                        </td>
                    </tr>
                </table>
                <div class="text-center">
                    <div class="btn btn-success" id="addToCart">
                        <span class="glyphicon glyphicon-plus"> Add to Cart</span>
                    </div>
                </div>
            </div>
            <div class="col-md-5 col-md-pull-7">
                <img class="img-responsive center-block" src="<%=artworkBase+artwork.getImageFileName()+suffix%>"
                     alt="Generic placeholder image">
            </div>
        </div>
        <div class="row">
            <h3>Descriptions: </h3>
            <p class="lead" id="description">
                <%=artwork.getDescription()!=null? artwork.getDescription():artwork.getDefaultDescription()%>
            </p>
        </div>
        <div class="row">
            <h3>Share to:</h3>
            <%@include file="jiaThisShare.jsp"%>
        </div>
    </div>

    <br>
    <div class="divider"></div>

    <%@include file="footer.jsp"%>
    <!-- Bootstrap core JavaScript
        ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="js/buy.js"></script>
</body>
</html>

